<template>
    <div class="home">
      <!-- 用户信息区域 -->
      <div class="user-info">{{ userInfo.realName }}</div>
  
      <div class="menu">
        <div class="menu-group">
          <router-link to="/repairForm" class="menu-item">
            <div class="menu-item-content">
              <div class="icon-wrapper">
                <i class="van-icon van-icon-records"></i>
              </div>
              <span class="text">提交报修</span>
            </div>
            <i class="van-icon van-icon-arrow"></i>
          </router-link>
  
          <router-link to="/repairList" class="menu-item">
            <div class="menu-item-content">
              <div class="icon-wrapper">
                <i class="van-icon van-icon-clock-o"></i>
              </div>
              <span class="text">我的报修</span>
            </div>
            <i class="van-icon van-icon-arrow"></i>
          </router-link>

          <router-link to="/repairInfo" class="menu-item" v-if="isShow">
            <div class="menu-item-content">
              <div class="icon-wrapper">
                <i class="van-icon van-icon-info-o"></i>
              </div>
              <span class="text">我的任务</span>
            </div>
            <i class="van-icon van-icon-arrow"></i>
          </router-link>

          <router-link to="/repairNotes" class="menu-item" v-if="isShow">
            <div class="menu-item-content">
              <div class="icon-wrapper">
                <i class="van-icon van-icon-notes-o"></i>
              </div>
              <span class="text">我的工单</span>
            </div>
            <i class="van-icon van-icon-arrow"></i>
          </router-link>
        </div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref, onMounted } from 'vue'
  import { useRouter } from 'vue-router'
  import * as dd from 'dingtalk-jsapi'
  import { ifShowMyWork } from "@/api/common"
  
  const router = useRouter();
  const isShow = ref(false);
  const userInfo = ref(JSON.parse(localStorage.getItem("SAVE_USER_INFO")));
  
  onMounted(() => {
    ifShowMyWork({userId: userInfo.value.userId}).then(res => {
      isShow.value = res
    })
  })
  </script>
  
  <style scoped>
  .home {
    min-height: 100vh;
    background-color: #f7f8fa;
  }

  /* 用户信息区域样式 */
  .user-info {
    padding: 16px;
    font-size: 20px;
    font-weight: 600;
    color: #323233;
  }
  
  .menu {
    padding: 12px;
  }
  
  .menu-group {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
  
  .menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    text-decoration: none;
    color: #323233;
    border-bottom: 1px solid #ebedf0;
  }
  
  .menu-item:last-child {
    border-bottom: none;
  }
  
  .menu-item-content {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .icon-wrapper {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1989fa;
  }
  
  .icon-wrapper i {
    font-size: 20px;
  }
  
  .text {
    font-size: 16px;
  }
  
  .van-icon-arrow {
    color: #969799;
    font-size: 16px;
  }
  </style>